<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>发表博客</title>

    <script src="/js/jquery-3.4.1.min.js" type="application/javascript"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/myblog.css">
    <link rel="stylesheet" href="/css/blog.css">
    <script src="/js/mybolg.js"></script>

</head>

<body>
<!-- Fixed navbar -->
<div th:replace="topbar :: top-bar"></div>


<div class="container" role="main">

    <div class="row publish">
        <div class="col-sm-12 blog-main">
            <div class="page-header">
                <h1>发布博客
                    <small>与别人共享你的经验</small>
                </h1>
            </div>
            <div class="alert alert-danger publish-lable-font" role="alert" th:if="${error != null}">
                <strong>警告:</strong><span th:text="${error}"></span>
            </div>
            <form action="/publish" method="post">
                <input type="hidden" name="id" th:value="${id}">
                <div class="form-group">
                    <label for="title" class="publish-lable-font">博客标题:</label>
                    <input th:value="${title != null}?${title}" type="text" class="form-control" name="title" id="title"
                           placeholder="问题标题……" autocomplete="off">
                </div>
                <div class="form-group" id="question-editor">
                    <label for="description" class="publish-lable-font">博客内容：</label>
                    <textarea th:text="${content}" name="content" class="form-control"
                              id="description" cols="30" rows="3" style="height: 240px;"></textarea>
                </div>

                <div class="form-group">
                    <label class="publish-lable-font">来源类型:</label><br/>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" type="radio" name="type" value="0"
                               th:checked="${blog!=null} ? ${blog.type==0}">
                        <label class="form-check-label publish-lable-font">原创</label>
                        <input class="form-check-input" type="radio" name="type" value="1"
                               th:checked="${blog!=null} ? ${blog.type==1}">
                        <label class="form-check-label publish-lable-font">转载</label>
                    </div>
                </div>

                <div class="form-group">
                    <label for="tag" class="publish-lable-font">添加标签：</label>
                    <input th:value="${tag != null}?${tag}" type="text" class="form-control" name="tag" id="tag"
                           placeholder="输入标签，以逗号分隔" autocomplete="off" onclick="showSelectTag()">
                    <div id="select-tag" class="publish-tag-tab">
                        <ul class="nav nav-tabs" role="tablist">
                            <li role="presentation" th:each="selectCategory,selectCategoryStat: ${tags}"
                                th:class="${selectCategoryStat.first ? 'active':''}">
                                <a th:href="${'#'+selectCategory.categoryName}" aria-controls="home" role="tab"
                                   data-toggle="tab" th:text="${selectCategory.categoryName}"
                                   class="publish-lable-font"></a>
                            </li>
                        </ul>
                        <div class="tab-content">
                            <div role="tabpanel" th:id="${selectCategory.categoryName}"
                                 th:each="selectCategory: ${tags}"
                                 th:class="${selectCategoryStat.first ? 'active tab-pane':'tab-pane'}">
                                <span class="label label-info blog-tag"
                                      onclick="selectTag(this)" th:data-tag="${selectTag}"
                                      th:each="selectTag: ${selectCategory.tags}">
                                    <span class="glyphicon glyphicon-tags"></span>
                                    <span th:text="${selectTag}"></span>
                                </span>

                            </div>
                        </div>
                    </div>
                </div>
                <div>
                    <button type="submit" class="btn btn-success btn-publish pull-right">发布</button>
                </div>


        </div><!-- /.blog-main -->

    </div>


</div> <!-- /container -->


<footer class="blog-footer">
    <p>Blog template built for <a href="http://getbootstrap.com">Bootstrap</a> by <a
            href="https://twitter.com/mdo">@mdo</a>.</p>
    <p>
        <a href="#">Back to top</a>
    </p>
</footer>

</body>
</html>
